package database

import (
	"log"

	"github.com/spf13/viper"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var MDB *gorm.DB
var err error

func MysqlInit() {
	mysqlAddress := viper.GetString("mysql.address")
	MDB, err = gorm.Open(mysql.Open(mysqlAddress), &gorm.Config{})
	if err != nil {
		log.Println("Failed to init Mysql")
		panic(err)
	}
	// log.Println("Mysql connected")
}
